#ifndef _GETAMMO_H
#define _GETAMMO_H
#include "global.h"
#include <mutex>

using namespace std;
typedef pcl::PointXYZ PointT;

extern char mode;
extern pcl::console::TicToc tt;
extern float y_min_getammo;
extern float y_max_getammo;

class SimpleOpenNIViewer
{
public:
	SimpleOpenNIViewer(); // Construct a cloud viewer, with a window name

	void cloud_cb_(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud);
	void run();
	pcl::visualization::CloudViewer viewer;

protected:
	pcl::PointXYZ min_point_AABB;
	pcl::PointXYZ max_point_AABB;
	Eigen::Vector3f major_vector, middle_vector, minor_vector;
	Eigen::Vector3f mass_center;
	pcl::MomentOfInertiaEstimation<PointT> feature_extractor;
	float z_angle, real_angle, lenght, diff_angle;

private:
	pcl::PassThrough<PointT> pass; //直通滤波对象
	pcl::VoxelGrid<PointT> sor;

	pcl::NormalEstimationOMP<PointT, pcl::Normal> ne; //法线估计对象
	pcl::IntegralImageNormalEstimation<PointT, pcl::Normal> ne1;
	pcl::SACSegmentationFromNormals<PointT, pcl::Normal> seg; //分割对象
	pcl::ExtractIndices<PointT> extract;											//点提取对象
	//pcl::search::KdTree<PointT>::Ptr tr ee(new pcl::search::KdTree<PointT>());
	pcl::EuclideanClusterExtraction<PointT> ec;
	pcl::PointCloud<pcl::Normal>::Ptr normals;

	pcl::PointCloud<PointT>::Ptr cloud_filtered;
	pcl::PointCloud<PointT>::Ptr cloud_viewer;
	pcl::PointCloud<pcl::Normal>::Ptr cloud_normals;
	pcl::ModelCoefficients::Ptr coefficients_cylinder;
	pcl::PointIndices::Ptr inliers_cylinder;
	pcl::search::Search<pcl::PointXYZ>::Ptr tree;
	//pcl::PointCloud<PointT>::Ptr cloud_plane(new pcl::PointCloud<PointT>());
	pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normal_estimator;
	pcl::RegionGrowing<pcl::PointXYZ, pcl::Normal> reg;
	pcl::console::TicToc tt_test;
};

#endif
